import useToast from "@/hooks/useToast";

const { sexList } = useToast();

export const filters = {
	// 获取性别值
	sexName: (sex) => {
		const pp = sexList.find((obj) => obj.value == sex);
		return pp ? pp.name : "";
	},
	millisecondFormat: (milliseconds) => {
		var totalSeconds = Math.ceil(milliseconds / 1000); // 将毫秒转换为秒
		var minutes = Math.floor(totalSeconds / 60); // 获取分钟数
		var remainingSeconds = totalSeconds % 60; // 获取剩余的秒数

		// 补0操作，确保时间格式总是两位数
		minutes = (minutes < 10 ? "0" : "") + minutes;
		remainingSeconds = (remainingSeconds < 10 ? "0" : "") + remainingSeconds;

		// 返回格式化的时间字符串
		return minutes + ":" + remainingSeconds;
	},
};